﻿using BackOfficeApplication.Models;
using BackOfficeApplication.Views;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BackOfficeApplication.Controlers
{
    public class ArticleCtrl
    {
        private ArticleUi _ui;
        public ArticleCtrl()
        {
            _ui = new ArticleUi(this);

            _ui.Show();
        }

        public System.ComponentModel.BindingList<ComboBoxDto> GetCategories()
        {
            var result = new System.ComponentModel.BindingList<ComboBoxDto>();
            var service = new BackOfficeService.BackOfficeServiceClient();
            var categories = service.GetCategories();
            foreach (var item in categories)
            {
                result.Add(new ComboBoxDto { Display = item.Name, Value = item.Id });
            }

            return result;
        }

        public void Reset()
        {
            _ui.BindingUI();
        }

        public void AddImage(ImageDto dto)
        {
            _ui.Model.Images.Add(dto);
        }
    }
}
